package com.tougutips.cookbook.entity;



import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 *
 * @TableName cookbook
 */
@TableName(value ="cookbook")
@Data
@Document(indexName = "cookbook")
public class Cookbook implements Serializable {
    /**
     * 主键
     */
    @TableId
    @Id
    @Field(type = FieldType.Keyword)
    private Long id;

    /**
     * userid
     */
    private Long userId;

    /**
     * 菜谱封面
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String cover;

    /**
     * 菜谱名字
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String cookbookName;

    /**
     * 菜谱烹饪时长
     */
    private String cookbookTime;

    /**
     * 菜谱难度的id
     */
    private Long difficultType;

    /**
     * 菜谱所属分类的id
     */
    private Long categoryId;

    /**
     * 菜谱的访问量(暂定每个人点一次)
     */
    private Integer visits;

    /**
     * 菜谱的收藏数
     */
    private Integer collectors;

    /**
     * 点赞量
     */
    private Integer likes;

    /**
     * 创建时间
     *  DEFAULT,
     *     INSERT,
     *     UPDATE,
     *     INSERT_UPDATE;
     */
    @TableField(fill =FieldFill.INSERT )
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField(fill =FieldFill.UPDATE )
    private Date updateTime;

    /**
     * 逻辑删除，1:删除，2:未删除
     */
    @TableLogic(delval = "1",value = "0")
    private String isDeleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Cookbook other = (Cookbook) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCover() == null ? other.getCover() == null : this.getCover().equals(other.getCover()))
            && (this.getCookbookName() == null ? other.getCookbookName() == null : this.getCookbookName().equals(other.getCookbookName()))
            && (this.getCookbookTime() == null ? other.getCookbookTime() == null : this.getCookbookTime().equals(other.getCookbookTime()))
            && (this.getDifficultType() == null ? other.getDifficultType() == null : this.getDifficultType().equals(other.getDifficultType()))
            && (this.getCategoryId() == null ? other.getCategoryId() == null : this.getCategoryId().equals(other.getCategoryId()))
            && (this.getVisits() == null ? other.getVisits() == null : this.getVisits().equals(other.getVisits()))
            && (this.getCollectors() == null ? other.getCollectors() == null : this.getCollectors().equals(other.getCollectors()))
            && (this.getLikes() == null ? other.getLikes() == null : this.getLikes().equals(other.getLikes()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCover() == null) ? 0 : getCover().hashCode());
        result = prime * result + ((getCookbookName() == null) ? 0 : getCookbookName().hashCode());
        result = prime * result + ((getCookbookTime() == null) ? 0 : getCookbookTime().hashCode());
        result = prime * result + ((getDifficultType() == null) ? 0 : getDifficultType().hashCode());
        result = prime * result + ((getCategoryId() == null) ? 0 : getCategoryId().hashCode());
        result = prime * result + ((getVisits() == null) ? 0 : getVisits().hashCode());
        result = prime * result + ((getCollectors() == null) ? 0 : getCollectors().hashCode());
        result = prime * result + ((getLikes() == null) ? 0 : getLikes().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", cover=").append(cover);
        sb.append(", cookbookName=").append(cookbookName);
        sb.append(", cookbookTime=").append(cookbookTime);
        sb.append(", difficultType=").append(difficultType);
        sb.append(", categoryId=").append(categoryId);
        sb.append(", visits=").append(visits);
        sb.append(", collectors=").append(collectors);
        sb.append(", likes=").append(likes);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
